using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

using FreeFlow.Client;

namespace FreeFlow.WinFormsControls
{
	/// <summary>
	/// A status control.
	/// </summary>
	public class StatusControl : PictureBox, IFillable
	{
    /// <summary>
    /// Creates a new <see cref="StatusControl"/> instance.
    /// </summary>
		public StatusControl()
		{
      InitializeComponent();
    }
    #region IFillable Members

    /// <summary>
    /// Renders the status control with static layout information using the specified field.
    /// </summary>
    /// <param name="field">Field.</param>
    public void Render(FreeFlow.Client.Field field)
    {
      
    }

    /// <summary>
    /// Fills the status control with values from the specified field.
    /// </summary>
    /// <param name="field">Field.</param>
    public void Fill(FreeFlow.Client.Field field)
    {
      byte[] imageData = (field as StatusField).Image;
      if (imageData != null)
      {
        MemoryStream stream = new MemoryStream(imageData);
        Bitmap bitmap = new Bitmap(stream);
        Image = bitmap;
        Width = bitmap.Width;
        Height = bitmap.Height;
      }
    }

    private void InitializeComponent()
    {
      // 
      // StatusControl
      // 
      this.Cursor = System.Windows.Forms.Cursors.Hand;

    }

    /// <summary>
    /// Fills the field from the control.
    /// </summary>
    /// <param name="field">Field.</param>
    public void FillField(Field field)
    {
    }

    #endregion
  }
}
